package com.project.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("user")
public class UserController {
    @RequestMapping("login")
    public String login(String userName, String pwd, HttpServletRequest request){
        if("java".equalsIgnoreCase(userName)&&
        "123".equalsIgnoreCase(pwd)){
            //在session中记录登录信息
            request.getSession().setAttribute("loginUser", userName);

            return "/html/index.html";
        }

        return "/html/error.html";
    }
    @RequestMapping("add")
    @ResponseBody
    public String getInfo(String userName){
        System.out.println(userName);
        return userName;
    }
}
